<template>
  <div class="user-container">
    <!-- 面包屑导航 -->
    <!-- <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>用户管理</el-breadcrumb-item>
            <el-breadcrumb-item>用户列表</el-breadcrumb-item>
    </el-breadcrumb>-->
    <bread :second="'订单管理'" :third="'订单列表'"></bread>
    <!-- 卡片 -->
    <el-card class="box-card">
      <div style="margin-top: 15px;">
        <el-row :gutter="20">
          <el-col :span="8">
            <el-input placeholder="请输入内容" v-model="orderObj.query" class="iptBox">
              <el-button slot="append" icon="el-icon-search" @click="getOrders()"></el-button>
            </el-input>
          </el-col>
        </el-row>
      </div>
      <!-- 表格 -->
      <el-table :data="tableData" border="" style="width: 100%;margin:20px 0">
        <el-table-column type="index" width="50" label="#"></el-table-column>
        <el-table-column prop="order_number" label="订单编号" width="180"></el-table-column>
        <el-table-column prop="order_price" label="订单价格" width="180"></el-table-column>
        <el-table-column  label="是否付款">
          <template slot-scope="scoped">
            {{scoped.row.pay_status}}
            <el-tag v-if="!scoped.row.pay_status" type="success">已付款</el-tag>
            <el-tag v-else type="danger">未付款</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="is_send" label="是否发货"></el-table-column>
        <el-table-column  label="下单时间">
           <template slot-scope="scoped">
            ====={{scoped.row.create_time | format}}===
            
          </template>
        </el-table-column>
        
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button
              type="primary"
              size="mini"
              icon="el-icon-edit"
              @click="handleEdit(scope.row)"
            ></el-button>
            <el-button
              icon="el-icon-delete"
              size="mini"
              type="danger"
              @click="handleDelete(scope.row.id)"
            ></el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="orderObj.pagenum"
        :page-sizes="[10, 20, 30, 40]"
        :page-size="orderObj.pagesize"
        
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      ></el-pagination>


    </el-card>

  </div>
</template>
           
<script>
import {
  orders_api
} from '@/api'
export default {
  data() {
    return {
      tableData: [],
      total: 1,

      /* 分页中的当前页码数 */

      /* 获取数据列表参数对象 */
      orderObj: {
        query: '',
        pagenum: 1,
        pagesize: 5
      },
    }
  },
  created() {
    this.getOrders()
  },
  methods: {
    /* 分页组件提供的事件 */
    handleSizeChange(val) {
      //console.log(`每页 ${val} 条`)
       this.orderObj.pagesize = val
      this.getOrders()
    },
    handleCurrentChange(val) {
      //console.log(`当前页: ${val}`)
      //  将获取的当前页赋值给  pagenum
      this.orderObj.pagenum = val
      this.getOrders()
    },

  
   
    /* 删除用户 */
    async handleDelete(id) {
      //console.log(id, 444)

      const res2 = await this.$confirm(
        '此操作将永久删除该文件, 是否继续?',
        '提示',
        {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }
      ).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })

    },

 
   

    /* 获取用户数据列表 */
    async getOrders() {
      const { data: res } = await orders_api(this.orderObj)
     // console.log(res, 888)
      //  将获取的用户数据赋值给tableData
      this.tableData = res.data.goods
      this.total = res.data.total
    },


  
  }
}
</script>
<style scoped lang='less'>
.user-container {
  .el-breadcrumb {
    margin-bottom: 20px;
  }

  .box-card {
    .iptBox {
    }
  }
}
</style>